package unitrole

// RoleManager 角色管理
type RoleManager struct {
	allRoles map[uint64]*Role
}

var roleMgrInstance RoleManager

func RoleInstance() *RoleManager {
	return &roleMgrInstance
}

func (mgr *RoleManager) OnInit() {
	mgr.allRoles = make(map[uint64]*Role)
}

func (mgr *RoleManager) OnDestroy() {

}

func (mgr *RoleManager) OnRoleLogin(role *Role) {
	mgr.allRoles[role.Uid()] = role
}

func (mgr *RoleManager) GetRoleById(uid uint64) *Role {
	if r, ok := mgr.allRoles[uid]; ok {
		return r
	}
	return nil
}
